module.exports = {
  convertRGB: convertRGB
}

function convertRGB(data, tftWidth, tftHeight) {
  // 数据转换
  let buffer = new ArrayBuffer(tftWidth * tftHeight * 2)
  let dataView = new DataView(buffer)
  dataView.setUint8(0, 0)
  dataView.setUint8(byteOffset, value);
  let uint16
  let rVal, gVal, bVal
  let index = 0
  for (let i = 0; i < data.length; i += 4) {
    rVal = data[i] / 8 << 11
    gVal = data[i + 1] / 4 << 5
    bVal = data[i + 2] / 8
    uint16 = rVal & gVal & bVal
    dataView.setUint8((uint16 & 0xff00) >> 8)
    dataView.setUint8(uint16 & 0x00ff)
    index += 2
  }
  return buffer
}